package org.面试题.factoryMethods.order;


import org.面试题.factoryMethods.Pizza.Pizza;
import org.面试题.simpleFactory.Order.SimpleFactory;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * 订购pizza
 */
public abstract class OrderPizza {

    // TODO 定义一个抽象方法，createPizza，让各个工厂子类去自己实现
    abstract Pizza createType(String orderType);

    // 构造器
    public  OrderPizza() {
        Pizza pizza = null;
        String typePizza;
        do {
            typePizza = getType();
        pizza = createType(typePizza); // 抽象的创造方法，由工厂子类来实现

            // 输出pizza的制作过程

            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        } while (true);
    }





    public String getType(){
        try {
            BufferedReader string = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza 种类：");
            return string.readLine();
        }catch (Exception e){
            return " ";
        }
    }
}
